package br.edu.ufersa.scrumgame.facade;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import br.edu.ufersa.scrumgame.dao.SprintBacklogDAO;
import br.edu.ufersa.scrumgame.modelo.SprintBacklog;

@Stateless
public class SprintBacklogFacadeImp implements SprintBacklogFacade {
	
	@EJB
	private SprintBacklogDAO sprintBacklogDAO;
	
	@Override
	public void save(SprintBacklog sprintBacklog) {
		sprintBacklogDAO.save(sprintBacklog);
	}

	@Override
	public SprintBacklog update(SprintBacklog sprintBacklog) {
		return sprintBacklogDAO.update(sprintBacklog);
	}

	@Override
	public void delete(SprintBacklog sprintBacklog) {
		sprintBacklogDAO.delete(sprintBacklog);
		
	}

	@Override
	public SprintBacklog find(int entityID) {
		return sprintBacklogDAO.find(entityID);
	}
	
	@Override
	public List<SprintBacklog> findAll() {
		return sprintBacklogDAO.findAll();
	}

	@Override
	public List<SprintBacklog> findConcluidoByUser(String email) {
		return sprintBacklogDAO.findConcluidoByEmail(email);
	}

	@Override
	public SprintBacklog findNext(String email) {
		SprintBacklog retorno = null;
		
		List<SprintBacklog> itens = sprintBacklogDAO.findByEmail(email);
		
		if( itens.size() > 0) {
			retorno = itens.get(0);
		}
		
		return retorno;
	}

}
